A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.
This invention relates to compilers, and more particularly to a transformational programming system in which code can be inherited.
As computer technology has advanced, computer programs have become correspondingly complex to the point where it is very difficult for a programmer to write an application program in the machine language of the computer. Thus, most programs are written in a high-level language that is easier for the programmer to work with and then converted by a compiler into the machine language of the computer.
A co-pending application titled xe2x80x9cExtensible Compiler Architecturexe2x80x9d, Ser. No. 09/322,646, filed concurrently herewith, describes an extensible compiler architecture in which source code received by the compiler is represented as a graph having multiple nodes and interconnecting links. The compiler associates one or more question handlers with each node and uses a reduction engine to pass questions and answers among the question handlers. This question and answer methodology is used to transform the source code in graph form into another language.
The compiler also provides the code that describes the behavior of each of the question handlers. However, given the large number of nodes that can exist in a typical graph, having the compiler designer(s) separately write code for each question handler associated with each node can quickly become overburdening. Furthermore, given that the code for different question handlers may be very similar, if not the same, it would be beneficial to provide a way to avoid having to write the same code over and over for different question handlers.
The invention described below addresses these disadvantages, providing a transformational programming system that allows code to be inherited.
A transformational programming system is described herein that allows code to be inherited. A question and answer methodology is used among question handlers corresponding to nodes of a graph representing the program being transformed. A question handler can inherit code from another question handler by submitting a question requesting the code.
According to one aspect of the invention, when a question handler corresponding to a node receives a question, the question handler submits another question to another question handler corresponding to another node. This other question is a request for a set of instructions to execute in order to respond to the question it received. Eventually, the question handler will receive a response to this other question, the response being the set of instructions to execute in order to respond to the question it received.
According to another aspect of the invention, communication between question handlers is carried out via a reduction engine. The reduction engine also maintains a record of questions that are asked as well as responses given. When a question is received from a question handler requesting a set of instructions to execute, the reduction engine checks whether it has already answered the same question for another question handler. If it has already answered the same question, then the reduction engine provides the set of instructions from the record it maintains rather than submitting the question to another of the question handlers.
According to another aspect of the invention, a first question handler that receives a request from a second question handler for a set of instructions to execute may not know itself what set of instructions the second question handler should execute. Rather, the first question handler submits a request to a third question handler corresponding to yet another node in the graph, requesting a set of instructions for the second question handler to execute. This chain of questioning can continue through multiple additional question handlers until eventually a question is submitted to a question handler that knows the set of instructions the second question handler should execute. A response including this set of instructions is then passed back down through the chain of question handlers, eventually reaching the second question handler.